{include file="../app/view/common/header.html" subtitle="用户设置" page="user"}

<link rel="stylesheet" href="/static/user/set.css">

<script src="/static/jquery/jquery-ui/jquery-ui.min.js"></script>
<script src="/static/jquery/jquery.iframe-transport.min.js"></script>
<script src="/static/jquery/jquery-ui/jquery-ui.min.js"></script>
<script src="/static/jquery/jquery-fileupload/jquery.fileupload.js"></script>

<script src="/static/user/set.js"></script>


<script>
    if (window.location.href.indexOf("first") != -1)
        Swal.fire("首次登录，建议快去修改密码（只要你的密码还是123456就会一直要你修改的！（）")
</script>

<div class="set-item">
    <h1>修改密码</h1>
    <div class="mdui-textfield">
        <input class="mdui-textfield-input" type="password" placeholder="新密码" id="pass1"/>
    </div>
    <div class="mdui-textfield">
        <input class="mdui-textfield-input" type="password" placeholder="重复密码" id="pass2"/>
    </div>
    <button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-accent" onclick="resetPassword()">修改密码</button>
    <button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-accent" onclick="exitLogin()">退出登录</button>
    （使用王子鉴自研算法加密，极度安全）
    <h1> </h1>
</div>
<div class="mdui-divider"></div>

<div class="set-item">
    <h1>个人信息</h1>（加密后存储，非必要不读取）
    <label class="mdui-textfield-label">选择题：</label>
    <div id="choose_div">
        
    </div>
    <label class="mdui-textfield-label">填空题：</label>
    <div id="text_div">
        
    </div>
    

    <h1> </h1>
    <button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-accent" onclick="saveInfo()">保存全部！</button>
</div>
<div class="mdui-divider"></div>
<div class="set-item">
    <h1>修改头像</h1>
    <img id="facer" style="width: 300px">
    <input type="file" style="display: none;" id="upload" accept="image/png, image/jpeg" name="facer">
    <button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-accent" onclick="initFileChoser();document.getElementById('upload').click()">点击上传</button>
    <h1> </h1>
</div>
<div class="mdui-divider"></div>

<script src="/static/laydate/laydate.js"></script>
<script>
    getFacer(document.getElementById('facer'))
    function a(c,e) {
        o = new Object()
        o.e = e
        o.c = c
        return o
    }
    items = [
        a("手机号码","phone_number"),
        a("外号","other_name"),
        a("家乡","home_town"),
        a("生日","birthday"),
        a("星座","star"),
        a("班内职务","job"),
        a("学院","university"),
        a("宿舍","bed"),
        a("QQ","qq"),
        a("WeChat","wechat"),
        a("身高","height"),
        a("体重","weight"),
        a("爱好","love"),
        a("特长","nb"),
        a("喜欢的异性类型","like"),
        a("记忆中的第一个梦想","old_dream"),
        a("现在最大的梦想","now_dream"),
        a("认为大学中最重要的事","important"),
        a("人生格言","life"),
        a("自己最满意的一点","satisfaction"),
    ]
    for (i = 0; i<items.length; i++) {
        sub = ""
        if (items[i].e == "star") {
            sub = `<div class="mdui-textfield">
            <label class="mdui-textfield-label">`+items[i].c+`</label>
            <input class="mdui-textfield-input" type="text" id="star" disabled/>
        </div>`
        } else {
            type = 'text'
            if (items[i].e == "height" || items[i].e == "weight") {
                type = `number`
            }
            sub = `<div class="mdui-textfield">
            <label class="mdui-textfield-label">`+items[i].c+`</label>
            <input class="mdui-textfield-input" type="`+type+`" id="`+items[i].e+`"/>
            </div>`
            
        }
        document.getElementById("text_div").innerHTML += sub
        
    }
    document.getElementById("university").value = "经济与管理学院"
    //执行一个laydate实例
    laydate.render({
        elem: '#birthday',
        done: function(){
            getStar()
        }
    });
flag = false
function getStar() {
    bir = document.getElementById("birthday").value
    flag = !flag
    aDate = dateParse(bir)
    document.getElementById("star").value = getZodiacSign(aDate[1],aDate[2])
}
function dateParse(dateString){  
    var SEPARATOR_BAR = "-";  
    var SEPARATOR_SLASH = "/";  
    var SEPARATOR_DOT = ".";  
    var dateArray;  
    if(dateString.indexOf(SEPARATOR_BAR) > -1){  
        dateArray = dateString.split(SEPARATOR_BAR);    
    }else if(dateString.indexOf(SEPARATOR_SLASH) > -1){  
        dateArray = dateString.split(SEPARATOR_SLASH);  
    }else{  
        dateArray = dateString.split(SEPARATOR_DOT);  
    }  
    return dateArray
};  

function getZodiacSign(getMonth,getDay){
    var res = ""
	var lastDay = (getDay <= 30),FebDay = (getDay <= 29); //用于限制当月最大天数
  if(getDay >= 1 || getDay <= 31){
    
getMonth = parseInt(getMonth)
getDay = parseInt(getDay)
  switch (getMonth){
    case 1://1月星座
      if(getDay <= 19){res = '摩羯座';}else if(getDay >= 20){res = '水瓶座';}break;
    case 2: //2月星座
      if(getDay <= 18){res = '水瓶座';}else if(getDay >= 18 && FebDay){res = '双鱼座';}break;
    case 3://3月星座
      if(getDay <= 20){res = '双鱼座';}else if(getDay >= 21){res = '白羊座';}break;
    case 4: //4月星座
      if(getDay <= 19){res = '白羊座';}else if(getDay >= 20 && lastDay){res = '金牛座';}break;
    case 5://5月星座
      if(getDay <= 20){res = '金牛座';}else if(getDay >= 21){res = '双子座';}break;
    case 6://6月星座
      if(getDay <= 21){res = '双子座';}else if(getDay >= 22 && lastDay){res = '巨蟹座';}break;
    case 7://7月星座
      if(getDay <= 22){res = '巨蟹座';}else if(getDay >= 23){res = '狮子座';}break;
    case 8://8月星座
      if(getDay <= 22){res = '狮子座';}else if(getDay >= 23){res = '处女座';}break;
    case 9://9月星座
      if(getDay <= 22){res = '处女座';}else if(getDay >= 23 && lastDay){res = '天秤座';}break;
    case 10://10月星座
      if(getDay <= 23){res = '天秤座';}else if(getDay >= 24){res = '天蝎座';}break;
    case 11://11月星座
      if(getDay <= 22){res = '天蝎座';}else if(getDay >= 23 && lastDay){res = '射手座';}break;
    case 12://12月星座
      if(getDay <= 21){res = '射手座';}else if(getDay >= 22){res = '摩羯座';}break;
  	}
    
	}return res
}
</script>